package com.wantong.jianpu.dialogs;

import android.content.Context;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.CenterPopupView;
import com.wantong.jianpu.R;

import me.goldze.mvvmhabit.utils.StringUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;

/**
 * @author PACY
 * @date 2022/5/6
 * description:
 */
public class ReBackPopupView extends CenterPopupView {
    public GdthCallBack callBack;

    private EditText remark_et;
    private TextView save_tv;
    public ReBackPopupView(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.reback_popup_view;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        findViewById(R.id.close_tv).setOnClickListener((v) -> {
            dismiss();
        });

        remark_et=findViewById(R.id.remark_et);
        save_tv=findViewById(R.id.save_tv);
        save_tv.setOnClickListener(v -> {
            if(StringUtils.isEmpty(remark_et.getText().toString())){
                ToastUtils.show("请输入退回原因");
                return;
            }

            if(callBack!=null){
                callBack.success(remark_et.getText().toString());
                dismiss();
            }
        });
    }

    public void setCallBack(GdthCallBack callBack){
        this.callBack=callBack;
    }

    public interface GdthCallBack{
        void success(String remark);
    }
}
